package com.delivery.www.service.ServiceImpl;

import com.delivery.www.dao.OrderDao;
import com.delivery.www.dao.DaoImpl.OrderDaoImpl;
import com.delivery.www.po.Order;
import com.delivery.www.service.OrderService;
import com.delivery.www.util.JdbcUtils;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public class OrderServiceImpl implements OrderService {
    private OrderDao orderDao;

    public OrderServiceImpl() {
        orderDao = new OrderDaoImpl();
    }

    @Override
    public boolean addOrder(int userId, int storeId, int dishId, Float money) {
        boolean flag = false;
        int i = orderDao.addOrder(userId, storeId, dishId, "未接单", money);
        if (i > 0) {
            flag = true;
        }
        return flag;
    }

    @Override
    public List<Order> getCompleteOrder(int storeId, String status) {
        List<Order> orders = null;
        orders = orderDao.getCompleteOrder(storeId, status);
        return orders;
    }

    @Override
    public Float earnings(int storeId) {
        Float f = null;
        f = orderDao.earnings(storeId, "完成");
        return f;
    }

    @Override
    public List<Order> getUnCompleteOrder(int storeId, String status) {
        List<Order> orders = null;
        orders = orderDao.getUnCompleteOrder(storeId, status);
        return orders;
    }

    @Override
    public boolean modifyStatus(int orderId, String status, int storeId) {
        boolean flag = false;
        int i = orderDao.modifyStatus(orderId, status, storeId);
        if (i > 0) {
            flag = true;
        }
        return flag;
    }

    @Override
    public List<Order> getOwnOrder(int userId) {
        List<Order> orders = null;
        orders = orderDao.getOwnOrder(userId);
        return orders;
    }
}
